package com.huli.configuration;

import org.springframework.context.annotation.Configuration;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2020-11-21
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */
@Configuration
public class AlipayConfig {
    //↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "2016110100784721";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCJX5BglRRa6AfXe9Sa9bNb8PJYdEasW0HWaW1SOLUMiNf9VVUhrE9AztVzmfg+LYlt4Eyxci06BcQu2UMbxa8aaJqNIl7Y0rXViu4cikuMYD0ZHxEH+f9VySFQAchSACED+uvAU5pGmJuAkF4Nch8gPIYbchpYCy2T3qAKVbI/FCbKpe8rAFbi5hGSUjB9JohHR0SJVDLwma3OxYUevX23VC16Cn2Cu9KnUr7PQXmbo8YG/uaHd4HGcJpVvSVpjWUucFd7ZFgtiWWfGMt5ImO7GV7FxrLFBn1dKM2tLDK2LSbarKNEhKAhrJw3T2QY6JX1q8mVE+p/1TvnwNo1hluFAgMBAAECggEAGDw90mw6nRcWWxPDnFsAe5X0i1poJXwsD1GmMb1DY6S4xj7JuBkYGkzjJ3PgccfC2RmbLisAg54E0GcQCdREYhpWOdP4e7Qg1D2gaHSVg3xvCwGKFagrPc0wDVdjKeRP7s3TzahyLUY7GOFfVmvtxdgnqKvmreW68r1x6qDXw3zeBrO5fNofhntxjaaoB6vXBpmZEIwqKUkowQ3VoeLkgwAesdCDmVEMXufaGUi0gj1i/lRCqhuqKvHI1kjOLYHIiM7qdIm5BSCeO70TqJv2L4qhpM9x7Mhc8+ztFNbDQJUjkb/HMnjJUzopUucFS822WMiNOLF+E0baSEVU67qJeQKBgQDSfw252ntoSSeTmbXPf26SB/gMg4FaYtJQJgkXw5E8Eopg+/E1wuwaii4AGH+iaXB/Zwz2f72PeTymD6FDdbk5ujNISeQGzJVeVaeMPzYo7pdCPwSpguLk3tw1HFsfmg32Xm69Hu5RJFJG9CDFjKrBjOm5+1x0Q4bzIXYWCJL8CwKBgQCnEdrk7ZmD6M/k/lGXil1BQMHJT+HA6zse58gw9dd9bZkBdNxyy8w6To71KCXsvbGtMMRZMbMIQKCsfVZ1c8NitMVg862hEb0tDWjvZBat8hYfjMz1MXAfX3sddtN2wtax3E5Z8Pqz3bOvFs2L7kMB69DZ8jj4/Hk0Snw/kZ4wrwKBgBtxNPjl4vDVmLNFds52bpPbNhtriZGfEIwiaU0P0f9i62d5cRjxMJbFLPoWN42U8XWqmaYJQU1TIPUFVKDW2C8Od2EVQQUh5tdFk3JVS1pKwK2CSblPtwTfiRXjfH3CN8/Gv+kn/ynU8mUNrrgSfrB9DnuQqZz+sLlBw4Nb2s3BAoGAGxk0TgmT6udqQRRXG6NfuOPOCt8gGPCOqFakC/z0NO3/8VKJJz2TJKn1WiJm9F1YYmUUk/sRtPb2mMPDsE1UlcAIe89KjGOaMaKJMLslSpWHrRpjbCnWq+AK0h6h8hNsS3EWbFQ/9ciyCmZCdL3ytG8RcyhswUYCSs8CFDWEWRUCgYA4axiL/HridoYNoYC3Ong6S0K2X9Kr6j/VQ+1gIkybfk/wytJJTR9Eif9dN80aBKZAR99HQrWmnbf5UXYSZNGdubd/qOZkBrypvo06mqiWe1mErNlK6onywyGzeua/CbjQtCB9TBn9NWtdoLesL54YKKVZwLsqGbUj+vJgsRrFHQ==";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoEjDaqUk/gut1WlI1vcOFrZ+ZCucRg+rBI9SmyPH6qGz5jTo1IwkC2z3+GfVoY0eyae7/rYuweb7WrOOnm2jKT5hQaTdX+23BbHx5l1YkbYlhl+JwnO07HT61N2hLDpWwVdfhr2HINoCwJ1yXWUduFb7MbttT1VXAIZ6cC1ejmAfQ654rBpW6cPAOzGIXG4B7rLivMKn40x2nzKFk/H45HsyBOeh6JSe5ALQdShY4TdfOpUwW7iUXmam57RZ/2sM0W4I2m6SjFpF6S40bD62goMGULCgan6v2sPxjKTArqdCyFlXDh1F2lnftlx9MJtO1irMYS36w1v99PBBJTn9gQIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "http://3od5635509.zicp.vip/error";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String return_url = "http://3od5635509.zicp.vip/index";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     *
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis() + ".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
